<?php
/**
 * Accessed from view.php. Adds a placeholder to the given resourcepage,
 * then redirects back to view.
 *
 * @copyright &copy; 2006 The Open University
 * @author s.marshall@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package package_name
 *//** */
  
    require_once("module_resourcepage.php");
    $module=module_resourcepage::$inst;
 
    $id=required_param('id',PARAM_INT); // Course Module ID
    $placeholder=required_param('placeholder',PARAM_ALPHA); // Placeholder string
    $scrollpos=optional_param('scrollpos',0,PARAM_INT);
    
    $module->obtain_view_info($id,null,$cm,$course,$resourcepage);
    
    // Security checks
    $module->verify_edit_action($cm);

    // Add placeholder
    $added=$module->add_placeholder_instance($placeholder,$course->id,$resourcepage->containerid);    
        
    // Log and return to view
    add_to_log($course->id, "resourcepage", "additem", "view.php?id=$cm->id",
        "Added placeholder #"+$added,$cm->id);
    redirect('view.php?id='.$cm->id.($scrollpos ? '&scrollpos='.$scrollpos : '')); 
?>